﻿@using SchoolPointe.Menus.Enums
@using SchoolPointe.Menus.Models
@using Orchard.ContentManagement
@using Util

@{ 
    var part = ((IContent)Model.ContentItem).As<BetterMenuItemPart>();
    var title = part.Text;
    var description = "";
    if (part.MenuItemType == MenuItemType.CustomLink) {
        description = "Custom";   
    }
    else if (part.MenuItemType == MenuItemType.ContentItem)
    {
        if (part.RelatedItem.Value != null)
        {
            description = part.RelatedItem.Value.ContentType;
        }     
    }
     
    var children = ShapeHelper.Find(Model.Editor, "MenuItemChildren_Editor");
}

        
<li class="menu-item-sortable-item">
    <div class="sp-menu-collapse">
        <h4><a href="#"><span class="item-title">@title</span><span class="menu-item-description">@description</span></a></h4>
        <div>
            <div class="edit-form">
                <input type="hidden" name="prefix" value="@Model.ParentPrefix" />
                @Display(Model.Child)
            </div>
            <a class="delete-menu-item" href="@Url.Action("Delete", "MenuItemAdmin", new { area = "SchoolPointe.Menus", id = part.Id })">Remove</a>
            <button class="secondaryAction saveMenuItem" value="@Url.Action("Edit", "MenuItemAdmin", new { area = "SchoolPointe.Menus", id = part.Id })">Save</button>                
            <span class="ajax-indicator">Saving...</span>
        </div>
    </div>

    <ol>
    @foreach (var editor in children.MenuItems)
    {
        @Display(editor)
    }               
    </ol>
</li>



